﻿/*
创建人：zhangrj
日期：2021-12-30
描述：叶片多订单批次创建页面js
*/

var page = {
    url: getRootPath() + "/Ashx/YePianContainer/YPOrderContainerStartHandler.ashx", //后台处理逻辑url
    queryFormData: { //查询所需的数据
        action: "GetContainerBaseInfo"
    },
    postFormData: { //保存提交时的数据
        action: "SaveContainerData"
    },
    containerFormData: {}, //批次填写的数据
    init: function () {
        page.bind();
        page.bindContainerInfo();
    },
    //初始化页面事件
    bind: function () {
        //批次列表
        $("#gdOrderContainerView").datagrid({
            columns: [[
		         { field: 'mfgordername', title: '生产订单', width: 120 },
                 { field: 'conNumber', title: '可开卡数', width: 80,
                     formatter: function (value, row, index) {
                         if (value == null || value == "") {
                             return row.qty;
                         } else {
                             return parseInt(row.qty) - parseInt(value);
                         }
                     }
                 },
                  { field: 'productName', title: '零件号', width: 120 },
                  { field: 'productDescription', title: '零件名称', width: 180 },
                   { field: 'WorkflowName', title: '工艺流程', width: 150 },
                  { field: 'containerType', title: '批次类型', width: 150,
                      formatter: function (value, row, index) {
                          if (value == "2") {
                              return "批量加工";
                          }
                          if (value == "3") {
                              return "批量带子序号";
                          } else {
                              return "";
                          }
                      }
                  },
                  { field: 'containerName', title: '流水卡', width: 150 },
                  { field: 'containerNo', title: '批次编号', width: 100 },
                  { field: 'containerQty', title: '数量', width: 60,
                      formatter: function (value, row, index) {
                          if (value == undefined || value == null || value == "") {
                              if (row.conNumber == "" || row.conNumber == null) {
                                  value = row.qty;
                              } else {
                                  value = parseInt(row.qty) - parseInt(row.conNumber);
                              }
                          }
                          return value;
                      }
                  },
                  { field: 'workCenterName', title: '主制工区', width: 120 },
                  { field: 'workCenter', title: '', hidden: true },
                  { field: 'teamName', title: '主制班组', width: 120 },
                  { field: 'team', title: '', hidden: true },
                  { field: 'techniqueName', title: '工艺员', width: 120 },
                  { field: 'technique', title: '', hidden: true },
                  { field: 'PlannedStartDate', title: '计划开始日期', width: 120, editor: 'datebox' },
                  { field: 'PlannedCompletionDate', title: '计划结束日期', width: 120, editor: 'datebox' },
                  { field: 'containerComments', title: '备注', width: 100 },
                  { field: 'qty', title: '', hidden: true },
                  { field: 'startWorkflowStep', title: '', width: 100, hidden: true },
                  { field: 'startWorkflowStepName', title: '', width: 100, hidden: true },
                  { field: 'containerCardNo', title: '', width: 100, hidden: true },
                  { field: 'heatNo', title: '', width: 100, hidden: true },
                  { field: 'productFamily', title: '', width: 100, hidden: true },
                  { field: 'materialType', title: '', width: 100, hidden: true },
                  { field: 'uOMField', title: '', width: 100, hidden: true },
                  { field: 'uOMFieldName', title: '', width: 100, hidden: true },
                  { field: 'productID', title: '', width: 100, hidden: true },
                  { field: 'WorkflowID', title: '', width: 100, hidden: true },
                  { field: 'MfgOrderID', title: '', width: 100, hidden: true },
                  { field: 'OrderTypeID', title: '', width: 100, hidden: true },
                  { field: 'militaryType', title: '', width: 100, hidden: true },
                  { field: 'ypContainerType', title: '', width: 100, hidden: true }
                ]],
            onDblClickCell: function (index, field, value) {
                if (field == 'PlannedStartDate' || field == 'PlannedCompletionDate') {
                    $(this).datagrid('beginEdit', index);
                    var ed = $(this).datagrid('getEditor', { index: index, field: field });
                    $(this).datagrid('checkRow', index);
                }
            },
            onClickRow: function (rowIndex, rowData) {
                $(this).datagrid('acceptChanges');
                if (isNullOrWhiteSpaceStr(rowData.containerName)) {
                    displayMessage("数据信息不全，请先预览数据", false);
                    return;
                }
                if (rowData.containerType === "3") {
                    if (parseInt(rowData.qty) - parseInt(rowData.conNumber) > 1000) {
                        displayMessage("开卡数量过多，预览子序号将不显示", false);
                        return;
                    }
                    page.bindChildContainerTable(rowData); //绑定子序号列表
                }
            }
        });
        //机型列表
        $("#gdProductFamily").datagrid({
            columns: [[
             { field: 'ck', title: '选择', width: 20, checkbox: true },
		         { field: 'PRODUCTFAMILYNAME', title: '机型', width: 150 }
                ]]
        });
        //子序号列表
        $("#gdChikdContainer").datagrid({
            columns: [[
		         { field: 'childContainerName', title: '子批次号', width: 180 },
                  { field: 'childContainerQty', title: '数量', width: 150 },
                   { field: 'childBeginStep', title: '开始工序', width: 180 }
                ]]
        });
        //批次类型选择事件
        $("input[name='radContainerType']").on("click", function () {
            if ($(this).val() == "2") {
                $("#chidSection").hide(); //如果是批量加工，隐藏子序号列表
            } else {
                $("#chidSection").show(); //如果是批量子序号，显示子序号列表
            }
        });
        //预览按钮事件
        $('#btnContainerView').on("click", function () {
            displayMessage("", true);
            if (page.isContainerVaild()) {
                var newrows = [];
                var crows = $("#gdOrderContainerView").datagrid('getRows');
                if (crows.length == 0) {
                    displayMessage("未有订单数据", false);
                    return;
                }
                else if (crows.length > 1) {//如果是多个订单批次
                    var contaienrname = "";
                    var containerno = "";
                    if (page.containerFormData.ypContainerType === "2") {//如果是机加
                        for (var i = 0; i < crows.length; i++) {
                            containerno = page.containerFormData.containerNoPrefix + "" + page.getJiJiaContaienrNo(i) + "" + page.containerFormData.containerNoSuffix; //前部+中间可变序号+后部分
                            contaienrname = page.containerFormData.containerName + "" + containerno;
                            newrows.push($.extend({}, crows[i], page.containerFormData, { containerName: contaienrname, containerNo: containerno }));
                        }
                    } else {
                        var numdiff = "";
                        for (var i = 0; i < crows.length; i++) {
                            numdiff = page.getContainerNameSuffix((i + 1));
                            contaienrname = page.containerFormData.containerName + numdiff; //在批次后追加数字顺序
                            containerno = page.containerFormData.containerNo + numdiff; //在批次编号后追加数字顺序
                            newrows.push($.extend({}, crows[i], page.containerFormData, { containerName: contaienrname, containerNo: containerno }));
                        }
                    }
                }
                //如果只有一条订单批次
                else {
                    if (page.containerFormData.ypContainerType === "2") {//如果是机加
                        page.containerFormData.containerNo = page.containerFormData.containerNoPrefix + "" + page.containerFormData.containerNoCenter + "" + page.containerFormData.containerNoSuffix; //前部+中间可变序号+后部分
                        page.containerFormData.containerName = page.containerFormData.containerName + "" + page.containerFormData.containerNo;
                    }
                    newrows.push($.extend({}, crows[0], page.containerFormData));
                }
                //更新订单批次列表数量
                $("#gdOrderContainerView").datagrid('loadData', { rows: newrows });
            }
        });
        //备注弹窗
        $('#openCommentDialog').on("click", function () {
            $("#winFormDialog").openDialog({
                title: '选择批次备注',
                url: '/InSiteWebApplication/forms/Custom/YePian/YPContainerCommentDialog.html',
                left: 30,
                top: 20,
                callback: function (data) {
                    if (data.outParam != undefined) {
                        $('#txtRemark').textbox("setValue", data.outParam)
                    }
                }
            });
        });
        //开卡并继续
        $('#btnStart').on("click", function () {
            page.postData("1");
        });
        //开卡并关闭
        $('#btnStartAndClosed').on("click", function () {
            page.postData("2");
        });
        //关闭
        $('#btnClose').on("click", function () {
            parent.window.close();
        })
    },
    //初始化页面，绑定批次填写的基础数据
    bindContainerInfo: function () {
        //绑定批次类型
        var containerType = getParam("containerType");
        var ypContainerType = getParam("ypContainerType");
        if (isNullOrWhiteSpaceStr(ypContainerType)) {
            displayMessage("数据丢失", false);
            return;
        }
        if (isNullOrWhiteSpaceStr(containerType) == false) {
            $("input[name='radContainerType']").each(function () {
                if ($(this).val() == containerType) {
                    $(this).attr("checked", "checked");
                } else {
                    $(this).attr("disabled", "disabled");
                }
            });
        }
        if (containerType == "2") {
            $("#chidSection").hide(); //如果是批量加工，隐藏子序号列表
        }
        if (ypContainerType == "2") { //如果是机加，隐藏热处理顺序号、卡片号、批次编号
            $('#divDuanjian').hide();
        } else {
            $('#divJijia').hide();
        }
        page.containerFormData.ypContainerType = ypContainerType;
        //绑定其他数据
        $.ajax({
            type: "Post",
            url: page.url,
            data: page.queryFormData,
            cashe: false,
            success: function (data) {
                var result = JSON.parse(data);
                if (result.Result) {
                    page.initPageData(result.DBDataSet);
                    displayMessage("数据准备完成", true);
                    return;
                }
                displayMessage(result.Message, false);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    },
    //初始化页面数据（后台获取数据绑定）
    initPageData: function (datas) {
        //订单批次列表
        $("#gdOrderContainerView").datagrid('loadData', { rows: datas.orderContainers });
        //件号
        $("#selProductNo").combobox({
            valueField: 'PRODUCTID',
            textField: 'PRODUCTNAME',
            data: datas.subSectionProductDt, //下拉数据
            value: datas.orderContainers[0].productID, //默认值
            onSelect: function (record) {
                page.bindWorkFlowListDatas(record.PRODUCTNAME);
            }
        });
        //工艺路线
        $("#selWorkflowName").combobox({
            valueField: 'WORKFLOWID',
            textField: 'WORKFLOWNAME',
            data: datas.sectionWorkFlowDt, //下拉数据
            value: datas.orderContainers[0].WorkflowID, //默认值
            onSelect: function (record) {
                page.bindStepListDatas(record.WORKFLOWID);
            }
        });
        //主制工区
        $("#selWorkCenter").combobox({
            valueField: 'WORKCENTERID',
            textField: 'WORKCENTERNAME',
            data: datas.sectionWcDt, //下拉数据
            onSelect: function (record) { //下拉时动态获取班组
                $.ajax({
                    type: "Post",
                    url: page.url,
                    data: { action: "GetTeams", workcenterID: record.WORKCENTERID },
                    cashe: false,
                    success: function (data) {
                        var result = JSON.parse(data);
                        //主制班组
                        $("#selTeam").combobox('clear');
                        $("#selTeam").combobox({
                            valueField: 'TEAMNAME',
                            textField: 'TEAMNAME',
                            data: result.DBTable //下拉数据
                        });
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        displayMessage(XMLHttpRequest.responseText, false);
                    }
                });
            }
        });
        //工艺员
        $("#selTechnique").combobox({
            valueField: 'EMPLOYEENAME',
            textField: 'FULLNAME',
            data: datas.sectionEmployDt //下拉数据
        });
        //单位
        $("#selUOMField").combobox({
            valueField: 'UOMID',
            textField: 'UOMNAME',
            data: datas.sectionUOMDt, //下拉数据
            onLoadSuccess: function () { //加载数据成功后
                for (var i = 0; i < datas.sectionUOMDt.length; i++) {
                    if (datas.sectionUOMDt[i].UOMNAME == "件") {
                        $('#selUOMField').combobox('setValue', datas.sectionUOMDt[i].UOMID);
                    }
                }
            }
        });
        //机型下拉框
        $("#selfamilyType").combobox({
            valueField: 'FamilyTypeId',
            textField: 'FamilyTypeName',
            data: [{ FamilyTypeId: "1", FamilyTypeName: "批产" }, { FamilyTypeId: "2", FamilyTypeName: "主研" }, { FamilyTypeId: "3", FamilyTypeName: "参研"}], //下拉数据
            value: "1", //默认值
            onSelect: function (record) { //下拉时动态获取数据
                $.ajax({
                    type: "Post",
                    url: page.url,
                    data: { action: "GetProductFamily", FamilyType: record.FamilyTypeId },
                    cashe: false,
                    success: function (data) {
                        var result = JSON.parse(data);
                        $("#gdProductFamily").datagrid('loadData', { rows: result.DBTable });
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        displayMessage(XMLHttpRequest.responseText, false);
                    }
                });
            }
        });
        $('#txtProduct').textbox("setValue", datas.orderContainers[0].productName); //设置批次号前部分
    },
    //动态绑定工艺下拉列表
    bindWorkFlowListDatas: function (productName) {
        displayMessage("", true);
        $.ajax({
            type: "Post",
            url: page.url,
            dataType: 'json',
            data: { action: "GetWorkFlowListDatas", productName: productName },
            cashe: false,
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (result) {
                $.messager.progress('close');
                //
                if (result.Result) {
                    $("#selWorkflowName").combo('clear');
                    $("#selWorkflowName").combobox({
                        valueField: 'WORKFLOWID',
                        textField: 'WORKFLOWNAME',
                        data: result.DBTable, //下拉数据
                        value: result.DBTable[0].WorkflowID //默认值
                    });
                }
                else {
                    $("#selWorkflowName").combo('clear');
                    $("#selWorkflowName").combo("panel").empty();
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combo("panel").empty();
                    displayMessage(result.Message, false);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    },
    //动态绑定工序下拉列表
    bindStepListDatas: function (workflowId) {
        displayMessage("", true);
        $.ajax({
            type: "Post",
            url: page.url,
            dataType: 'json',
            data: { action: "GetStepListDatas", workFlowID: workflowId },
            cashe: false,
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (result) {
                $.messager.progress('close');
                //开始工序
                if (result.Result) {
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combobox({
                        valueField: 'WORKFLOWSTEPID',
                        textField: 'WORKFLOWSTEPNAME',
                        data: result.DBTable, //下拉数据
                        value: result.DBTable[0].WORKFLOWSTEPID //默认值
                    });
                }
                else {
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combo("panel").empty();
                    displayMessage(result.Message, false);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    },
    //验证批次填写数据是否完整,并填充填写的数据
    isContainerVaild: function () {
        page.containerFormData.militaryType = $("#selMilitaryType").combobox('getValue'); //客户类型，不需要验证必填
        if (isNullOrWhiteSpaceStr(page.containerFormData.ypContainerType)) {
            displayMessage("叶片批次类型数据丢失", false);
            return false;
        }
        page.containerFormData.containerType = $("input[name='radContainerType']:checked").val(); //批次类型
        if (isNullOrWhiteSpaceStr(page.containerFormData.containerType)) {
            displayMessage("未选择批次类型", false);
            return false;
        }
        page.containerFormData.materialType = $("input[name='radMaterialType']:checked").val(); //领料类型
        if (isNullOrWhiteSpaceStr(page.containerFormData.materialType)) {
            displayMessage("未选择领料类型", false);
            return false;
        }
        page.containerFormData.productID = $("#selProductNo").combobox('getValue'); //件号ID
        page.containerFormData.productName = $("#selProductNo").combobox('getText'); //件号名
        if (isNullOrWhiteSpaceStr(page.containerFormData.productID)) {
            displayMessage("未选择件号", false);
            return false;
        }
        page.containerFormData.WorkflowID = $("#selWorkflowName").combobox('getValue'); //工艺路线ID
        page.containerFormData.WorkflowName = $("#selWorkflowName").combobox('getText'); //工艺路线名
        if (isNullOrWhiteSpaceStr(page.containerFormData.WorkflowID)) {
            displayMessage("未选择工艺路线", false);
            return false;
        }
        page.containerFormData.startWorkflowStep = $("#selStartWorkflowStep").combobox('getValue'); //开始工序
        page.containerFormData.startWorkflowStepName = $("#selStartWorkflowStep").combobox('getText'); //开始工序名
        if (isNullOrWhiteSpaceStr(page.containerFormData.startWorkflowStep)) {
            displayMessage("未选择开始工序", false);
            return false;
        }
        page.containerFormData.workCenter = $("#selWorkCenter").combobox('getValue'); //主制工区
        page.containerFormData.workCenterName = $("#selWorkCenter").combobox('getText'); //主制工区名
        if (isNullOrWhiteSpaceStr(page.containerFormData.workCenter)) {
            displayMessage("未选择主制工区", false);
            return false;
        }
        page.containerFormData.team = $("#selTeam").combobox('getValue'); //主制班组
        page.containerFormData.teamName = $("#selTeam").combobox('getText'); //主制班组名
        if (isNullOrWhiteSpaceStr(page.containerFormData.team)) {
            displayMessage("未选择主制班组", false);
            return false;
        }
        page.containerFormData.technique = $("#selTechnique").combobox('getValue'); //工艺员
        page.containerFormData.techniqueName = $("#selTechnique").combobox('getText'); //工艺员名
        if (isNullOrWhiteSpaceStr(page.containerFormData.technique)) {
            displayMessage("未选择工艺员", false);
            return false;
        }
        //        page.containerFormData.containerQty = $('#txtQty').textbox('getValue'); //批次数量
        //        if (isNullOrWhiteSpaceStr(page.containerFormData.containerQty)) {
        //            displayMessage("未填写批次数量", false);
        //            return false;
        //        }
        page.containerFormData.uOMField = $("#selUOMField").combobox('getValue'); //单位
        page.containerFormData.uOMFieldName = $("#selUOMField").combobox('getText'); //单位名
        if (isNullOrWhiteSpaceStr(page.containerFormData.uOMField)) {
            displayMessage("未选择单位", false);
            return false;
        }
        page.containerFormData.containerComments = $("#txtRemark").textbox('getText'); //备注
        //        page.containerFormData.startDate = $("#txtStartDate").datebox('getValue'); //开始日期
        //        if (isNullOrWhiteSpaceStr(page.containerFormData.startDate)) {
        //            displayMessage("未选择开始日期", false);
        //            return false;
        //        }
        //        page.containerFormData.completionDate = $("#txtCompletionDate").datebox('getValue'); //结束日期
        //        if (isNullOrWhiteSpaceStr(page.containerFormData.completionDate)) {
        //            displayMessage("未选择结束日期", false);
        //            return false;
        //        }
        var famliyrow = $("#gdProductFamily").datagrid('getChecked'); //机型
        if (famliyrow.length == 0) {
            displayMessage("未选择机型", false);
            return false;
        }

        //批次号处理
        var txtProduct = $.trim($('#txtProduct').textbox('getValue'));
        if (isNullOrWhiteSpaceStr(txtProduct)) {
            displayMessage("未填写批次号前部分", false);
            return false;
        }
        var txtLinkChar = $.trim($('#txtLinkChar').textbox('getValue'));
        if (isNullOrWhiteSpaceStr(txtLinkChar)) {
            displayMessage("未填写批次号连接符", false);
            return false;
        }
        var txtHeatNo = "";
        var txtContainerCardNo = "";
        var txtContainer = "";
        if (page.containerFormData.ypContainerType == "1") { //如果是锻件
            txtHeatNo = $.trim($('#txtHeatNo').textbox('getValue')); //热处理顺序号
            txtContainerCardNo = $.trim($('#txtContainerCardNo').textbox('getValue')); //卡片号
            txtContainer = $.trim($('#txtContainer').textbox('getValue')); //批次编号
            if (isNullOrWhiteSpaceStr(txtContainer)) {
                displayMessage("未填写批次编号(锻批号)", false);
                return false;
            }
            page.containerFormData.containerName = txtProduct + "" + txtLinkChar + "" + txtHeatNo + "" + txtContainer;
        }
        else { //如果是机加
            var txtContainerPrefix = $.trim($('#txtContainerPrefix').textbox('getValue'));
            //            if (isNullOrWhiteSpaceStr(txtContainerPrefix)) {
            //                displayMessage("未填写批次编号(前段)", false);
            //                return false;
            //            }
            page.containerFormData.containerNoPrefix = txtContainerPrefix;
            var txtContainerCenter = $.trim($('#txtContainerCenter').textbox('getValue'));
            if (isNullOrWhiteSpaceStr(txtContainerCenter)) {
                displayMessage("未填写批次编号(可变序号部分)", false);
                return false;
            }
            if (isNaN(txtContainerCenter) && typeof txtContainerCenter !== 'number') {
                displayMessage("批次编号(可变序号部分)只能为数字", false);
                return false;
            }
            page.containerFormData.containerNoCenter = txtContainerCenter;
            page.containerFormData.containerNoSuffix = $.trim($('#txtContainerSuffix').textbox('getValue'));
            page.containerFormData.containerName = txtProduct + "" + txtLinkChar;
        }
        page.containerFormData.heatNo = txtHeatNo;
        page.containerFormData.containerCardNo = txtContainerCardNo;
        page.containerFormData.containerNo = txtContainer; //批次编号
        return true;
    },
    //绑定子序号列表
    bindChildContainerTable: function (row) {
        var childRows = [];
        var cnum = parseInt(row.qty) - parseInt(row.conNumber);
        for (var i = 1; i <= cnum; i++) {
            var crow = { childContainerName: row.containerName + page.getContainerNameSuffix(i), childContainerQty: 1, childBeginStep: row.startWorkflowStepName };
            childRows.push(crow);
        }
        $("#gdChikdContainer").datagrid('loadData', { rows: childRows });
    },
    //提交数据
    postData: function (btype) {
        displayMessage("", true);
        $('#btnStart').linkbutton('disable'); //禁用按钮
        $('#btnStartAndClosed').linkbutton('disable'); //禁用按钮
        $("#gdOrderContainerView").datagrid('acceptChanges');
        var rows = $("#gdOrderContainerView").datagrid('getRows');
        if (rows.length == 0) {
            displayMessage2("未有订单数据", false, ["btnStart", "btnStartAndClosed"]);
            return;
        }
        if (isNullOrWhiteSpaceStr(rows[0].containerName)) {
            displayMessage2("请点击预览，查看数据是否完整，再开卡", false, ["btnStart", "btnStartAndClosed"]);
            return;
        }
        var famliyrow = $("#gdProductFamily").datagrid('getChecked'); //机型
        if (famliyrow.length == 0) {
            displayMessage2("未选择机型", false, ["btnStart", "btnStartAndClosed"]);
            return;
        }
        page.postFormData.containerDatas = JSON.stringify(rows); //订单数据
        page.postFormData.famliyDatas = JSON.stringify(famliyrow); //机型数据
        $.ajax({
            type: "Post",
            url: page.url,
            data: page.postFormData,
            cashe: false,
            success: function (data) {
                var result = JSON.parse(data);
                if (btype == "2") {
                    parent.window.returnValue = result.Message;
                    parent.window.close();
                }
                displayMessage2(result.Message, result.Result, ["btnStart", "btnStartAndClosed"]);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                displayMessage2(XMLHttpRequest.responseText, false, ["btnStart", "btnStartAndClosed"]);
            }
        });
    },
    //获取批次后缀
    getContainerNameSuffix: function (index) {
        if (parseInt(index) < 10) {
            return "0" + index
        } else {
            return index;
        }
    }
    //获取机加类型的批次号中间部分
    , getJiJiaContaienrNo: function (index) {
        var len = (page.containerFormData.containerNoCenter + '').length;
        var no = (parseInt(page.containerFormData.containerNoCenter,10) + index) + '';
        for (var i = no.length; i < len; i++) {
            no = "0" + no;
        }
        return no;
    }
};
page.init();